<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<script type='text/javascript' src="../js/popcorn-complete.js"></script>
	<script type="text/javascript" src="../js/jquery.min.js"></script>
	<script type='text/javascript' src="../js/d3.v2.js"></script>
	<script type='text/javascript' src="../js/d3.time.js"></script>
	<script type='text/javascript' src="../js/d3.layout.cloud.js"></script>
	<script type='text/javascript' src="../js/selectsontexte.js"></script>
	<script type='text/javascript' src="../js/selectbar.js"></script>
	<script type='text/javascript' src="../js/tagcloud.js"></script>
	<script type='text/javascript' src="../js/deleuze.js"></script>

	<link rel="stylesheet" href="../css/deleuze.css" />
	
	<script>

		var db = "flux_DeleuzeSpinoza";
	</script>	
	
</head>
<body>

	<?php foreach($this->resultats as $r) : ?>
		<div class="ref" id="ref_<?php echo $r['doc_id']; ?>" >
	    	<audio controls='controls' id='audioW_<?php echo $r['doc_id']; ?>' src='<?php echo $r['urlSonLocal']; ?>' ></audio>
			<?php echo $r['doc_id']." - ".$r['titre']; ?>
			<a href="<?php echo $r['url']; ?>"><?php echo $r['url']; ?></a>
			<div id="divSVG_<?php echo $r['doc_id']; ?>" style="display:none" ></div>
			<div class="posi" id="posi_<?php echo $r['doc_id']; ?>" >
				<table>
					<tbody id="table_<?php echo $r['doc_id']; ?>">
					<?php
						 $j = 0;
						 $i = 0;
						 foreach ($r['posis'] as $p) : 
						 			$oP = json_decode($p['note']);
						 			$idElem = $r['doc_id']."_".($i+$j)."_".$p['idDoc']."_".$oP->idExi."_".$j;
						 		?>
						 		<tr id="Select_exi_<?php echo $p['idDoc']; ?>">
						 			<td colspan="2" > 
								 		<div class="Select" id="Select_<?php echo $idElem; ?>" > 
											<span class="sonSelect" id="Select_son_<?php echo $idElem; ?>" ></span>
											<span class="status" id="status_<?php echo $idElem; ?>" ></span>
									 	</div>
									</td>
							 	</tr>
						 		<tr id="showSelect_<?php echo $idElem; ?>" >
						 			<td>
										<div class="txtSelect" id="Select_txt_<?php echo $idElem; ?>" ></div>
									</td>
						 			<td>
										<div class="tgcld" id="vis_<?php echo $idElem; ?>"></div>
									</td>
							 	</tr>
						<?php $j++; endforeach; ?>
					</tbody>					 
				</table>
			</div>		 			 	 
		</div>
	  	<script class="sst" >
	  	var sst = new selectsontexte({term:"<?php echo $this->term; ?>"
				, data:<?php echo json_encode($r); ?>
				, idDoc:"<?php echo $r['doc_id']; ?>"
				, idExi:-1});
	  	</script>
		<hr/>
	<?php endforeach; ?>
	<script>
		activeTag();
		// create our popcorn instance
		var popcorn = sst.audioW.funzo({
			      start: sst.nbSecDeb,
			      end: sst.nbSecFin
			  });

		var states = function() {
		    
		    // store the readyState
		    var rdy = popcorn.readyState();
		    
		    if ( rdy === 0 ) {
		        console.log( "No data at all, readyState is " + rdy );
		    } else if ( rdy === 1 ) {
		        console.log( "We have metadata, duration is " + popcorn.duration() +
		                     ", readyState is " + rdy );
		    } else if ( rdy === 2 ) {
		        console.log( "can play current location in video, readyState is " + rdy );
		    } else if ( rdy === 3 ) {
		        console.log( "can play current location in video and a bit more, readyState is " + rdy );
		    }
		    if ( rdy === 4 ) {
		        console.log( "can play whole video at current buffer rate, readyState is " + rdy );
			  	sst.audioW.funzo({
				      start: sst.nbSecDeb,
				      end: sst.nbSecFin
				  }).play(sst.nbSecDeb);
		    } else {
		        setTimeout( states, 10 );
		    }
		}
		    
		states();		
	</script>
  </body>
</html>
	